package com.zhkj.crawl.service.impl;

import com.zhkj.crawl.entity.Listing;
import com.zhkj.crawl.entity.ResultAmz;
import com.zhkj.crawl.service.TransactionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 事务处理
 */
@Service
@Slf4j
public class TransactionServiceImpl implements TransactionService {

    @Autowired
    private ListingService listingService;
    @Autowired
    private ResultAmzService resultAmzService;

    @Override
    @Transactional
    public boolean updateResultAmz(List<Listing> updateListing, List<ResultAmz> results){
        listingService.updateListings(updateListing);
        resultAmzService.batchInsert(results);
        return true;
    }

}
